package info.techgeek.labs.regex;

import info.techgeek.labs.String.StringSupplier;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class TableNameFetcher {

	public static void main(String args[]) throws IOException{
		
		StringSupplier stringSupplier = new StringSupplier();
		String string  = stringSupplier.getString();
		string = "";
		System.out.println("String length "+string.length());
		
		long t = System.currentTimeMillis(); 
		TableNameFetcher fetcher = new TableNameFetcher();
		
		List<String> list = (ArrayList<String>)fetcher.getQueryParams(string); 
		System.out.println("--------------------------------------------------");
		System.out.println("Time Taken For Split Logic :" +( System.currentTimeMillis() -t));
	}
	
	public List<String> getQueryParams(String query)
	{
		Pattern p = Pattern.compile("&[a-z0-9_\\-A-Z]+");
		Matcher m = p.matcher(query);
		List<String> aList = new ArrayList<String>(); 
		String str ;
		while (m.find())
		{
			str = m.group();
//			System.out.println(str);
			str = str.substring(1);
			if(!aList.contains(str))
				aList.add(str);
//			System.out.println(str);
		}
		return aList;
	}


}
